import axios from "axios";
// import axiosAdapterUniapp from 'axios-adapter-uniapp'
import {HOST_URL} from "./host.js"

// console.log(axiosAdapterUniapp);

// console.log(HOST_URL);
// console.log(axios);

const http = axios.create({
	baseURL:HOST_URL,
	// adapter: axiosAdapterUniapp
});

http.interceptors.response.use(
    function (response) {
        // 直接获取响应数据中的data
        return response.data;
    },
    function (error) {
        return Promise.reject(error);
    }
);

//get
export const _get = (req) => {
	// console.log(req);
    return http.get(req.url, { params: req.data });
};

//post
export const _post = (req) => {
	let { url ,data } = req
	// console.log(data);
    return http.post(url,data,{ headers: "application/x-www-form-urlencoded" });
};